<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tomcat配置文件详解</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            padding: 20px;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
        }
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 12px;
            color: white;
            font-size: 24px;
            margin-bottom: 20px;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 40px 0;
        }
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 20px 30px;
            border-radius: 12px;
            margin: 30px 0;
            font-weight: 500;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <h1 class="text-5xl font-bold mb-6 text-center">Tomcat配置文件详解</h1>
            <p class="text-xl text-center max-w-3xl mx-auto opacity-90">深入理解Apache Tomcat服务器的核心配置，掌握企业级Java Web应用部署的关键技术</p>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12">
        <!-- Introduction Section -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <h2 class="text-3xl font-bold mb-6 section-title">介绍</h2>
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">T</span>omcat服务器是一个开源的Servlet容器，用于托管Java Web应用程序。其主要作用是接收HTTP请求并将其转发到相应的Servlet或JSP进行处理，然后将处理结果返回给客户端。
            </p>
            <div class="mt-8">
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1711170840029-e7165e48-3716-42f5-bf92-110d77b93444.png" 
                     alt="Tomcat架构图" 
                     class="rounded-lg shadow-lg mx-auto">
            </div>
            <p class="text-lg leading-relaxed text-gray-700 mt-6">
                Tomcat的配置文件用于配置服务器的各种参数和行为，包括端口号、虚拟主机、连接器、数据源、安全性设置等。通过配置文件，管理员可以灵活地调整Tomcat服务器的行为，以满足不同应用程序的需求，并确保服务器的安全性和性能。
            </p>
        </div>

        <!-- Directory Structure Section -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <h2 class="text-3xl font-bold mb-6 section-title">目录结构</h2>
            <p class="text-lg leading-relaxed text-gray-700 mb-6">
                在Tomcat的目录结构中，与配置文件相关的部分主要包括以下几个目录和文件：
            </p>
            <div class="mb-8">
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1711170915359-b4ddd388-fa70-49ba-aa5b-9eda09b48bef.png" 
                     alt="Tomcat目录结构" 
                     class="rounded-lg shadow-lg mx-auto">
            </div>
            
            <div class="grid md:grid-cols-2 gap-6">
                <div class="bg-gray-50 rounded-lg p-6">
                    <div class="feature-icon">
                        <i class="fas fa-folder"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">conf 目录</h3>
                    <ul class="space-y-3 text-gray-700">
                        <li><strong>server.xml</strong>：Tomcat服务器的主要配置文件，定义服务器、服务、连接器等组件。</li>
                        <li><strong>web.xml</strong>：全局Web应用程序部署描述符，定义全局的Servlet、过滤器、监听器等。</li>
                        <li><strong>logging.properties</strong>：配置Tomcat的日志记录设置。</li>
                    </ul>
                </div>
                
                <div class="bg-gray-50 rounded-lg p-6">
                    <div class="feature-icon">
                        <i class="fas fa-cogs"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-4">其他重要目录</h3>
                    <ul class="space-y-3 text-gray-700">
                        <li><strong>lib</strong>：包含Tomcat服务器的类库文件</li>
                        <li><strong>logs</strong>：存储服务器的日志文件</li>
                        <li><strong>webapps</strong>：Web应用程序的部署目录</li>
                        <li><strong>work</strong>：存放运行时生成的工作文件</li>
                    </ul>
                </div>
            </div>
        </div>

        <!-- Configuration Relationship Diagram -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8">
            <h2 class="text-3xl font-bold mb-6 section-title">配置文件关系图</h2>
            <div class="mermaid">
                graph TD
                    A[Tomcat Server] --> B[server.xml]
                    B --> C[Service]
                    C --> D[Connector]
                    C --> E[Engine]
                    E --> F[Host]
                    F --> G[Context]
                    G --> H[web.xml]
                    B --> I[Executor线程池]
                    D --> I
                    
                    style A fill:#667eea,stroke:#764ba2,stroke-width:2px,color:#fff
                    style B fill:#f093fb,stroke:#f5576c,stroke-width:2px,color:#fff
                    style H fill:#f093fb,stroke:#f5576c,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- server.xml Section -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <h2 class="text-3xl font-bold mb-6 section-title">server.xml 配置详解</h2>
            <p class="text-lg leading-relaxed text-gray-700 mb-6">
                server.xml是Tomcat服务器的主要配置文件，它定义了Tomcat服务器的整体结构和行为。
            </p>
            
            <div class="grid md:grid-cols-3 gap-6 mb-8">
                <div class="text-center">
                    <div class="feature-icon mx-auto">
                        <i class="fas fa-server"></i>
                    </div>
                    <h4 class="font-bold text-lg mb-2">Server元素</h4>
                    <p class="text-gray-600">表示整个Tomcat服务器实例</p>
                </div>
                <div class="text-center">
                    <div class="feature-icon mx-auto">
                        <i class="fas fa-network-wired"></i>
                    </div>
                    <h4 class="font-bold text-lg mb-2">Service元素</h4>
                    <p class="text-gray-600">定义一个Tomcat服务</p>
                </div>
                <div class="text-center">
                    <div class="feature-icon mx-auto">
                        <i class="fas fa-plug"></i>
                    </div>
                    <h4 class="font-bold text-lg mb-2">Connector元素</h4>
                    <p class="text-gray-600">配置HTTP/HTTPS连接器</p>
                </div>
            </div>

            <h3 class="text-2xl font-bold mb-4">常见配置示例</h3>
            
            <div class="mb-6">
                <h4 class="text-lg font-semibold mb-3"><i class="fas fa-code mr-2 text-purple-600"></i>端口配置</h4>
                <div class="code-block">
                    <pre>&lt;Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" /&gt;</pre>
                </div>
            </div>

            <div class="mb-6">
                <h4 class="text-lg font-semibold mb-3"><i class="fas fa-globe mr-2 text-purple-600"></i>虚拟主机配置</h4>
                <div class="code-block">
                    <pre>&lt;Host name="example.com" appBase="webapps/example"
      unpackWARs="true" autoDeploy="true"&gt;
    &lt;Context path="" docBase="ROOT" /&gt;
&lt;/Host&gt;</pre>
                </div>
            </div>
        </div>

        <!-- web.xml Section -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <h2 class="text-3xl font-bold mb-6 section-title">web.xml 配置详解</h2>
            <p class="text-lg leading-relaxed text-gray-700 mb-6">
                web.xml是Java Web应用程序的部署描述符，用于配置和管理Web应用程序的各种组件和行为。
            </p>

            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-4 mb-8">
                <div class="bg-purple-50 rounded-lg p-4 text-center">
                    <i class="fas fa-cog text-3xl text-purple-600 mb-2"></i>
                    <h4 class="font-semibold">Servlet配置</h4>
                </div>
                <div class="bg-purple-50 rounded-lg p-4 text-center">
                    <i class="fas fa-filter text-3xl text-purple-600 mb-2"></i>
                    <h4 class="font-semibold">过滤器配置</h4>
                </div>
                <div class="bg-purple-50 rounded-lg p-4 text-center">
                    <i class="fas fa-headphones text-3xl text-purple-600 mb-2"></i>
                    <h4 class="font-semibold">监听器配置</h4>
                </div>
                <div class="bg-purple-50 rounded-lg p-4 text-center">
                    <i class="fas fa-exclamation-triangle text-3xl text-purple-600 mb-2"></i>
                    <h4 class="font-semibold">错误页面</h4>
                </div>
                <div class="bg-purple-50 rounded-lg p-4 text-center">
                    <i class="fas fa-clock text-3xl text-purple-600 mb-2"></i>
                    <h4 class="font-semibold">会话管理</h4>
                </div>
                <div class="bg-purple-50 rounded-lg p-4 text-center">
                    <i class="fas fa-database text-3xl text-purple-600 mb-2"></i>
                    <h4 class="font-semibold">上下文参数</h4>
                </div>
            </div>

            <h3 class="text-2xl font-bold mb-4">配置示例</h3>
            
            <div class="grid md:grid-cols-2 gap